package com.cll.learn.control.demo02;

import java.util.concurrent.CountDownLatch;

/**
 * 描述信息:
 *
 * @author CLL
 * @version 1.0
 * @date 2021/5/15 17:05
 */
public class ConcurrentThread implements Runnable {

    private final CountDownLatch countDownLatch;

    public ConcurrentThread(CountDownLatch countDownLatch) {
        this.countDownLatch = countDownLatch;
    }

    @Override
    public void run() {
        try {
            long entryTime = System.currentTimeMillis();
            System.out.println("线程" + Thread.currentThread().getName() + "进入时间" + entryTime);
            countDownLatch.await();
            long startTime = System.currentTimeMillis();
            System.out.println("线程" + Thread.currentThread().getName() + "开始时间" + startTime + "等待时间 = " + (startTime - entryTime));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
